import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store = new Vuex.Store({
	state: {
		token: '',
		memberInfo: {},
	},
	mutations: {
		setToken(state, token) {
			state.token = token
			uni.setStorageSync('token', token)
		},
		setMemberInfo(state, memberInfo) {
			state.memberInfo = memberInfo
		},
		logout(state) {
			state.token = ''
			state.memberInfo = {}
			uni.setStorageSync('token', '')
		}
	}
})

export default store